package com.lpb.spring.test1.factory.support;

import com.google.common.collect.Maps;
import com.lpb.spring.test1.factory.config.BeanDefinition;

import java.util.Map;

/**单例bean注册类
 * @author linpengbo
 * @date 2022/4/27
 */
public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFactory  implements BeanDefinitionRegistry{
   private Map<String,BeanDefinition> beanDefinitionMap= Maps.newConcurrentMap();
    @Override
    public void registerBeanDefinition(String beanName, BeanDefinition beanDefinition) {
        beanDefinitionMap.put(beanName,beanDefinition);
    }

    @Override
    protected BeanDefinition getBeanDefinition(String beanName) {
        BeanDefinition beanDefinition = beanDefinitionMap.get(beanName);
        if(beanDefinitionMap==null){
            throw new RuntimeException("");
        }
        return beanDefinition;
    }
}
